<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="文件名称" prop="fileName">
        <el-input
          v-model="queryParams.fileName"
          placeholder="请输入文件名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="list">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="文件名" align="center" prop="fileName" />
      <el-table-column
        label="文件大小"
        width="100"
        align="center"
        prop="fileSize"
      />
      <el-table-column
        label="文件哈希(Sha1)"
        align="center"
        prop="fileHashSha1"
      />
      <el-table-column
        label="文件哈希(Sha256)"
        align="center"
        prop="fileHashSha256"
      />
      <el-table-column
        label="文件哈希(MD5)"
        align="center"
        prop="fileHashMd5"
      />
      <el-table-column
        label="文件哈希(SM3)"
        align="center"
        prop="fileHashSm3"
      />
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listFile } from '@/api/file/share';

export default {
  name: 'Ware',
  data() {
    return {
      // 遮罩层
      loading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        fileName: null,
      },
      // 列表
      list: [],
      // 表单参数
      form: {
        courseId: null,
      },
      // 表单校验
      rules: {
        courseId: [
          { required: true, message: '所属课程不能为空', trigger: 'blur' },
        ],
        courseType: [
          { required: true, message: '课程类别不能为空', trigger: 'change' },
        ],
        wareName: [
          { required: true, message: '课件名称不能为空', trigger: 'blur' },
        ],
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询课件信息列表 */
    getList() {
      // this.loading = true;
      // listFile(this.queryParams).then((response) => {
      //   console.log(response);
      //   this.list = response.rows;
      //   this.total = response.total;
      //   this.loading = false;
      // });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        wareId: null,
        courseId: null,
        courseType: null,
        wareSort: null,
        wareName: null,
        wareDesc: null,
        wareCover: null,
        wareVideo: null,
        warePpt: null,
        wareFile: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
      };
      this.resetForm('form');
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
  },
};
</script>

<style lang="scss" scoped>
.sort-ware-modal {
  .ghost {
    opacity: 0.5;
    background: #c8ebfb;
  }
  .list-group-item {
    font-size: 16px;
    cursor: move;
  }
}
</style>
